package uniandes.cupi2.clienteJoy.interfaz;

import java.awt.*;
import java.util.ArrayList;

import javax.swing.*;

import uniandes.cupi2.collections.lista.Lista;
import java.awt.Dimension;
import java.awt.GridBagConstraints;

public class PanelTransferencias extends JPanel {

	private static final long serialVersionUID = 1L;
	@SuppressWarnings("unused")
	private InterfazJoyVE interfaz;
	private ArrayList<JLabel> lblNombres;
	@SuppressWarnings("unused")
	private ArrayList<PanelBarra> barras;
	private int numDescargas;
	private PanelBarra panelBarra = null;
	/**
	 * This is the default constructor
	 */
	public PanelTransferencias( InterfazJoyVE i ) {
		super();
		lblNombres = new ArrayList<JLabel>();
		barras = new ArrayList<PanelBarra>();
		numDescargas = 0;
		interfaz = i;
		initialize( );
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize(  )
	{
		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
		gridBagConstraints1.gridx = 0;
		gridBagConstraints1.gridheight = 0;
		gridBagConstraints1.gridwidth = 0;
		gridBagConstraints1.ipady = 41;
		gridBagConstraints1.gridy = 0;
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.fill = GridBagConstraints.VERTICAL;
		gridBagConstraints.gridy = 0;
		this.setLayout(new GridBagLayout());
		this.setPreferredSize(new Dimension(500, 300));
		this.add(getPanelBarra(), gridBagConstraints1);
		this.add(panelBarra, gridBagConstraints);
	}
	
	public void particionarBarra(int partes)
	{
		panelBarra.particionarBarra(partes);
	}
	
	public void agregarDescarga ( String n, int f )
	{
		GridBagConstraints gbcNombre = new GridBagConstraints();
		gbcNombre.gridx = 0;
		gbcNombre.gridy = numDescargas;
		JLabel nombre = new JLabel( );
		nombre.setText( n );
		nombre.setHorizontalAlignment( SwingConstants.LEFT );
		nombre.setFont( new Font( "Arial", Font.BOLD, 14 ) );
		nombre.setVerticalAlignment( SwingConstants.TOP );
		nombre.setSize( 50, 20 );
		lblNombres.add( nombre );
		// Barra de Descarga
		GridBagConstraints gbcBarra = new GridBagConstraints();
		gbcBarra.gridx = 1;
		gbcBarra.gridy = numDescargas;
		this.add( nombre, gbcNombre );
		panelBarra.setPreferredSize( new Dimension(this.getWidth(), 15 ));
		this.add( panelBarra, gbcBarra );
		numDescargas++;
	}

	public void actualizarListaDisponibles ( Lista<String> nuevaLista )
	{
		ArrayList<String> lista = new ArrayList<String>();
		for ( int i = 0 ; i < nuevaLista.darLongitud() ; i++ )
			lista.add( nuevaLista.darElemento(i).toString() );
		//listaDisponibles.setListData( lista.toArray( ) );
        //listaDisponibles.setSelectedIndex( 0 );
	}

	/**
	 * This method initializes panelBarra	
	 * 	
	 * @return uniandes.cupi2.clienteJoy.interfaz.PanelBarra	
	 */
	private PanelBarra getPanelBarra() {
		if (panelBarra == null) {
			panelBarra = new PanelBarra();
		}
		return panelBarra;
	}

}  //  @jve:decl-index=0:visual-constraint="56,74"
